<template>
  <div class="waitCheck">
    <h2 style="margin:20px 0">待批班级</h2>
    <Card>
      <Table :columns="columns1" :data="pageData"></Table>
      <Page
        :total="totali"
        size="small"
        show-elevator
        show-sizer
        :current="pageList.pagenum"
        :page-size="pageList.pagesize"
        @on-change="onchangePageNum"
        :page-size-opts="[1,2,3]"
        @on-page-size-change="onchangePageSize"
      />
    </Card>
  </div>
</template>
<script>
import { mapState, mapActions, mapMutations } from 'vuex'
export default {
  data() {
    return {
      arr: [],
      pageList: {
        pagesize: 3,
        pagenum: 1
      },
      total: 0,
      columns1: [
        {
          title: '班级名',
          key: 'grade_name'
        },
        {
          title: '课程名称',
          key: 'subject_text'
        },
        {
          title: '阅卷状态',
          key: 'status'
        },
        {
          title: '课程名称',
          key: 'subject_text'
        },
        {
          title: '成材率',
          key: 'room_text'
        },
        {
          title: 'Action',
          key: 'action',
          width: 150,
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h(
                'Button',
                {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.toGo(params.row)
                    }
                  }
                },
                '批卷'
              )
            ])
          }
        }
      ]
    }
  },
  computed: {
    ...mapState('waitCheck', ['checkInfo', 'pageData']),
    totali() {
      console.log(this.checkInfo.data.length)
      return this.checkInfo.data.length
      // return 10
    }
  },
  methods: {
    ...mapActions('waitCheck', ['getcheckList', 'getclassInfo']),
    ...mapMutations('waitCheck', ['getPage']),
    toGo(row) {
      console.log(row)
      this.$router.push({
        name: 'awaitclassmeta'
      })
      const data = {
        id: row.grade_id,
        className: row.grade_name
      }
      console.log(data)
      this.getclassInfo(data)
    },
    onchangePageNum(val) {
      this.pageList.pagenum = val
      this.getPage(this.pageList)
    },
    onchangePageSize(val) {
      this.pageList.pagesize = val
      this.getPage(this.pageList)
    }
  },
  created() {
    this.getcheckList()
  }
}
</script>

<style>
</style>
